export enum gameMenuType {
    // -1
    allGame    = 0,  //全部游戏
    hot        = 1,  //热门游戏
    morePerson = 2,  //多人
    chess      = 3,  //棋牌游戏
    videoGame  = 4,  //电子游艺
    liveVideo  = 5,  //真人视讯
    fishing    = 6,  //捕鱼
    nearest    = 7,  //最近玩过
    roomList   = 8,  //房间列表
    myRoom     = 9,  //我的房间
    contest    = 10, //比赛
    arcade     = 11, //街机
};


//
class GameChooseConfig {
    menu = {
        chat: 0, //聊天
        addressBook: 1, //通讯录
        club: 2, //俱乐部
        personal: 3, //个人中心
    };
    menus = [0, 1, 2, 3];
    contentPrefabPath = {
        0: "Modules/Chat/FriendListView",
        1: "Modules/AddressBook/TongXunLu/TongXunLuView",
        2: "Modules/Club/Club",
        3: "Modules/Personal/PersonalView/PersonalView"
    };

    gameHallState = {
        gameList: 0,  //游戏列表
        roomList1: 1,  //普通房间列表
        roomList2: 2,  //自建房间列表
        roomList3: 3,  //我的房间
        contest: 4,//比赛场
    };
    gameHallPrefabPath = {
        0: "Modules/Club/GameHall/GameList/GameList",
        1: "Modules/Club/GameHall/RoomSelect/RoomSelect",
        2: "Modules/Club/GameHall/RoomSelect/BuildRoom/BuildRoom",
    }

    menuType = {
        // -1
        allGame: 0, //全部游戏
        hot: 1, //热门游戏
        morePerson: 2, //多人
        chess: 3, //棋牌游戏
        videoGame: 4, //电子游艺
        liveVideo: 5, //真人视讯
        fishing: 6, //捕鱼
        nearest: 7, //最近玩过
        roomList: 8, //房间列表
        myRoom: 9, //我的房间
        contest: 10,//比赛
        arcade: 11, //街机
    };

    curMenu = 0;
    curMenuType = 0;
    //当前进入游戏时的页签
    curGameMenuType = -1

    //
    menuList = [10, 9, 8, 0, 1, 2, 3, 4];//, 6, 4, 5, 7]; //菜单列表
    /** 服务器提供页签数据 gameHall */
    curMenuList = [];
    gameSetMenuList = [0, 1];
    /**menuType作为下标 */
    gameType = {


        0: [],//全部
        1: [],//热门
        2: [102, 101, 115, 105, 103, 106, 104, 122],//多人
        3: [2, 6, 9, 7, 13, 22, 23, 130, 131, 132, 134, 135, 136],//棋牌游戏
        4: [118, 119, 52, 124],//电子游艺
        8: [],
        9: [],
        10: [],
        11: [],
    };

    //buildGames = [6, 7, 9, 13, 121];
    //    buildGames = [6, 7, 9, 10, 13, 53, 121, 130, 131, 132, 134, 135, 136, 137, 138];
    //    buildGames = [6, 7, 9, 10, 13, 53, 121, 130, 131, 132, 134, 135, 136, 137, 138,139];
    buildGames = [[7, 9, 15, 53, 121, 130, 131, 132, 134, 135, 136, 137, 138, 139, 141, 142, 143],//俱乐部
    [7, 9, 15, 121, 130, 131, 132, 134, 135, 136, 137, 138, 139, 141, 142, 143]//私人房
    ];

    menuInfo = {
        0: {
            //全部游戏
            menuName: "TK_an_qb",
            CHName: "全部游戏",
            kaifang: true,
            gameList: [
                2, 102, 101, 118, 119, 115, 6, 105, 9, 7, 53,
                22, 23, 103, 106, 104, 122, 130, 131, 132, 134, 135, 136, 137, 138, 139, 141, 142, 143
            ]
        },
        1: {
            //热门游戏(推荐)
            menuName: "TK_an_tj",
            CHName: "热门游戏",
            kaifang: true,
            gameList: [

            ]
        },
        2: {
            //多人
            menuName: "TK_an_brc",
            CHName: "多人游戏",
            kaifang: true,
            gameList: [106, 102, 101, 105, 115, 103, 104]
        },
        3: {
            //棋牌游戏
            menuName: "JLB_an_qpyx",
            CHName: "棋牌游戏",
            kaifang: true,

            gameList: [
                6, 2, 22, 23
            ],
        },
        4: {
            //电子游艺
            menuName: "JLB_an_dzyx",
            CHName: "电子游艺",
            kaifang: true,
            gameList: [118, 119,
            ]
        },
        5: {
            //真人视讯
            menuName: "JLB_dzyx",
            CHName: "真人视讯",
            kaifang: true,

            gameList: []
        },
        6: {
            //捕鱼
            menuName: "DT_fy_byyx",
            CHName: "捕鱼",
            kaifang: true,

            gameList: []
        },
        7: {
            //最近玩过
            menuName: "DT_zjwg",
            CHName: "最近玩过",
            kaifang: true,
            gameList: []
        },
        8: {
            //房间聊表
            menuName: "JLB_an_jlb",
            CHName: "俱乐部",
            kaifang: true,
            gameList: []
        },
        9: {//我的房间
            menuName: "JLB_an_wdfj",
            CHName: "我的房间",
            kaifang: true,
            gameList: []
        },
        10: {//比赛
            menuName: "JLB_an_bs",
            CHName: "比赛",
            kaifang: true,//开放 
            gameList: [],//
        }
    };

    gameListInfo = {
        2: {
            //抢庄牛牛
            kaifang: true,
            prefabName: "GameChooseIcon",
            iconName: "DT_qznn",
            atlasName: "ChooseGameIcon.plist",
            channel: "", // 渠道（BG, AG）
            type: 0,
            isRealPerson: false,
            game_type: "",
            pos: cc.v2(0, 0)
        },
        3: {
            //血战麻将
            kaifang: true,
            prefabName: "GameChooseIcon",
            iconName: "DT_xzmj",
            atlasName: "ChooseGameIcon.plist",
            channel: "", // 渠道（BG, AG）
            type: 0,
            isRealPerson: false,
            game_type: "",
            pos: cc.v2(0, 0)
        },
        6: {
            //扎金花
            kaifang: true,
            prefabName: "GameChooseIcon",
            iconName: "DT_zjh",
            atlasName: "ChooseGameIcon.plist",
            channel: "", // 渠道（BG, AG）
            type: 0,
            isRealPerson: false,
            game_type: "",
            pos: cc.v2(0, 0)
        },
        7: {
            //跑得快
            kaifang: true,
            prefabName: "GameChooseIcon",
            iconName: "DT_pdk",
            atlasName: "ChooseGameIcon.plist",
            channel: "", // 渠道（BG, AG）
            type: 0,
            isRealPerson: false,
            game_type: "",
            pos: cc.v2(0, 0)
        },
        9: {
            //斗地主
            kaifang: true,
            prefabName: "GameChooseIcon",
            iconName: "DT_ddz",
            atlasName: "ChooseGameIcon.plist",
            channel: "", // 渠道（BG, AG）
            type: 0,
            isRealPerson: false,
            game_type: "",
            pos: cc.v2(0, 0)
        },
        10: {
            //三公
            kaifang: true,
            prefabName: "GameChooseIcon",
            iconName: "DT_sg",
            atlasName: "ChooseGameIcon.plist",
            channel: "", // 渠道（BG, AG）
            type: 0,
            isRealPerson: false,
            game_type: "",
            pos: cc.v2(0, 0)
        },
        13: {
            //十三水
            kaifang: true,
            prefabName: "GameChooseIcon",
            iconName: "DT_sss",
            atlasName: "ChooseGameIcon.plist",
            channel: "", // 渠道（BG, AG）
            type: 0,
            isRealPerson: false,
            game_type: "",
            pos: cc.v2(0, 0)
        },
        14: {
            //二十一点
            kaifang: true,
            prefabName: "GameChooseIcon",
            iconName: "DT_esyd",
            atlasName: "ChooseGameIcon.plist",
            channel: "", // 渠道（BG, AG）
            type: 0,
            isRealPerson: false,
            game_type: "",
            pos: cc.v2(0, 0)
        },
        15: {
            //抢庄牌九
            kaifang: true,
            prefabName: "GameChooseIcon",
            iconName: "DT_qzpj",
            atlasName: "ChooseGameIcon.plist",
            channel: "", // 渠道（BG, AG）
            type: 0,
            isRealPerson: false,
            game_type: "",
            pos: cc.v2(0, 0)
        },
        21: {
            //血战麻将2人两房   1
            kaifang: true,
            prefabName: "GameChooseIcon",
            iconName: "DT_ermj",
            atlasName: "ChooseGameIcon.plist",
            channel: "", // 渠道（BG, AG）
            type: 0,
            isRealPerson: false,
            game_type: "",
            pos: cc.v2(0, 0)
        },
        22: {
            //通比牛牛
            kaifang: true,
            prefabName: "GameChooseIcon",
            iconName: "DT_tbnn",
            atlasName: "ChooseGameIcon.plist",
            channel: "", // 渠道（BG, AG）
            type: 0,
            isRealPerson: false,
            game_type: "",
            pos: cc.v2(0, 0)
        },
        23: {
            //随机牛牛
            kaifang: true,
            prefabName: "GameChooseIcon",
            iconName: "DT_sjnn",
            atlasName: "ChooseGameIcon.plist",
            channel: "", // 渠道（BG, AG）
            type: 0,
            isRealPerson: false,
            game_type: "",
            pos: cc.v2(0, 0)
        },

        52: {
            //捕鱼
            kaifang: true,
            prefabName: "GameChooseIcon",
            iconName: "DT_by",
            atlasName: "ChooseGameIcon.plist",
            channel: "", // 渠道（BG, AG）
            type: 0,
            isRealPerson: false,
            game_type: "",
            pos: cc.v2(0, 0)
        },
        53: {
            //德州扑克
            kaifang: true,
            prefabName: "GameChooseIcon",
            iconName: "DT_dzp",
            atlasName: "ChooseGameIcon.plist",
            channel: "", // 渠道（BG, AG）
            type: 0,
            isRealPerson: false,
            game_type: "",
            pos: cc.v2(0, 0)
        },
        54: {
            //西游捕鱼
            kaifang: true,
            prefabName: "GameChooseIcon",
            iconName: "DT_xyf",
            atlasName: "ChooseGameIcon.plist",
            channel: "", // 渠道（BG, AG）
            type: 0,
            isRealPerson: false,
            game_type: "",
            pos: cc.v2(0, 0)
        },
        100: {
            //红黑大战
            kaifang: true,
            prefabName: "GameChooseIcon",
            iconName: "DT_hhdz",
            atlasName: "ChooseGameIcon.plist",
            channel: "", // 渠道（BG, AG）
            type: 0,
            isRealPerson: false,
            game_type: "",
            pos: cc.v2(0, 0)
        },
        101: {
            //百家乐
            kaifang: true,
            prefabName: "GameChooseIcon",
            iconName: "DT_bjl",
            atlasName: "ChooseGameIcon.plist",
            channel: "", // 渠道（BG, AG）
            type: 0,
            isRealPerson: false,
            game_type: "",
            pos: cc.v2(0, 0)
        },

        102: {
            //龙虎斗   1
            kaifang: true,
            prefabName: "GameChooseIcon",
            iconName: "DT_lhd",
            atlasName: "ChooseGameIcon.plist",
            channel: "", // 渠道（BG, AG）
            type: 0,
            isRealPerson: false,
            game_type: "",
            pos: cc.v2(0, 0)
        },
        103: {
            //飞禽走兽
            kaifang: true,
            prefabName: "GameChooseIcon",
            iconName: "DT_fqzs",
            atlasName: "ChooseGameIcon.plist",
            channel: "", // 渠道（BG, AG）
            type: 0,
            isRealPerson: false,
            game_type: "",
            pos: cc.v2(0, 0)
        },
        104: {
            //抢红包
            kaifang: true, //是否开放
            prefabName: "GameChooseIcon", //预制体名
            iconName: "DT_qhb",
            atlasName: "ChooseGameIcon.plist",
            channel: "", // 渠道（BG, AG）
            type: 0, //类型
            isRealPerson: false, //是否是真人
            game_type: "", //游戏类型 第三方可用（yubu/shixun）
            pos: cc.v2(0, 0)
        },
        105: {
            //推筒子
            kaifang: true,
            prefabName: "GameChooseIcon",
            iconName: "DT_ttz",
            atlasName: "ChooseGameIcon.plist",
            channel: "", // 渠道（BG, AG）
            type: 0,
            isRealPerson: false,
            game_type: "",
            pos: cc.v2(0, 0)
        },
        106: {
            //百人牛牛
            kaifang: true,
            prefabName: "GameChooseIcon",
            iconName: "DT_brnn",
            atlasName: "ChooseGameIcon.plist",
            channel: "", // 渠道（BG, AG）
            type: 0,
            isRealPerson: false,
            game_type: "",
            pos: cc.v2(0, 0)
        },
        107: {
            //骰宝
            kaifang: true,
            prefabName: "GameChooseIcon",
            iconName: "DT_tb",
            atlasName: "ChooseGameIcon.plist",
            channel: "", // 渠道（BG, AG）
            type: 0,
            isRealPerson: false,
            game_type: "",
            pos: cc.v2(0, 0)
        },

        115: {
            //奔驰宝马
            kaifang: true,
            prefabName: "GameChooseIcon",
            iconName: "DT_bcbm",
            atlasName: "ChooseGameIcon.plist",
            channel: "", // 渠道（BG, AG）
            type: 0,
            game_type: "",
            pos: cc.v2(0, 0)
        },
        118: {
            //水浒传
            kaifang: true,
            prefabName: "GameChooseIcon",
            iconName: "DT_shz",
            atlasName: "ChooseGameIcon.plist",
            channel: "", // 渠道（BG, AG）
            type: 0,
            isRealPerson: false,
            game_type: "",
            pos: cc.v2(0, 0)
        },
        119: {
            //水果机(超级小玛丽)
            kaifang: true,
            prefabName: "GameChooseIcon",
            iconName: "DT_sgj",
            atlasName: "ChooseGameIcon.plist",
            channel: "", // 渠道（BG, AG）
            type: 0,
            isRealPerson: false,
            game_type: "",
            pos: cc.v2(0, 0)
        },
        120: {
            //水果小玛丽
            kaifang: true,
            prefabName: "GameChooseIcon",
            iconName: "DT_sg777",
            atlasName: "ChooseGameIcon.plist",
            channel: "", // 渠道（BG, AG）
            type: 0,
            isRealPerson: false,
            game_type: "",
            pos: cc.v2(0, 0)
        },
        121: {
            //牛王牛牛
            kaifang: true,
            prefabName: "GameChooseIcon",
            iconName: "DT_nwnn",
            atlasName: "ChooseGameIcon.plist",
            channel: "", // 渠道（BG, AG）
            type: 0,
            isRealPerson: false,
            game_type: "",
            pos: cc.v2(0, 0)
        },

        122: {
            //森林舞会
            kaifang: true,
            prefabName: "GameChooseIcon",
            iconName: "DT_slwh",
            atlasName: "ChooseGameIcon.plist",
            channel: "", // 渠道（BG, AG）
            type: 0,
            isRealPerson: false,
            game_type: "",
            pos: cc.v2(0, 0)
        },

        124: {
            //金玉满堂
            kaifang: true,
            prefabName: "GameChooseIcon",
            iconName: "DT_jymt",
            atlasName: "ChooseGameIcon.plist",
            channel: "", // 渠道（BG, AG）
            type: 0,
            isRealPerson: false,
            game_type: "",
            pos: cc.v2(0, 0)
        },

        130: {
            //郑州麻将
            kaifang: true,
            prefabName: "GameChooseIcon",
            iconName: "DT_zzmj",
            atlasName: "ChooseGameIcon.plist",
            channel: "", // 渠道（BG, AG）
            type: 0,
            isRealPerson: false,
            game_type: "",
            pos: cc.v2(0, 0)
        },
        131: {
            //血战麻将
            kaifang: true,
            prefabName: "GameChooseIcon",
            iconName: "DT_xzmj",
            atlasName: "ChooseGameIcon.plist",
            channel: "", // 渠道（BG, AG）
            type: 0,
            isRealPerson: false,
            game_type: "",
            pos: cc.v2(0, 0)
        },
        132: {
            //开封麻将
            kaifang: true,
            prefabName: "GameChooseIcon",
            iconName: "DT_kfmj",
            atlasName: "ChooseGameIcon.plist",
            channel: "", // 渠道（BG, AG）
            type: 0,
            isRealPerson: false,
            game_type: "",
            pos: cc.v2(0, 0)
        },
        133: {
            //三人两房
            kaifang: true,
            prefabName: "GameChooseIcon",
            iconName: "DT_srlf",
            atlasName: "ChooseGameIcon.plist",
            channel: "", // 渠道（BG, AG）
            type: 0,
            isRealPerson: false,
            game_type: "",
            pos: cc.v2(0, 0)
        },
        134: {
            //河南推倒胡
            kaifang: true,
            prefabName: "GameChooseIcon",
            iconName: "DT_tdh",//"DT_srlf",
            atlasName: "ChooseGameIcon.plist",
            channel: "", // 渠道（BG, AG）
            type: 0,
            isRealPerson: false,
            game_type: "",
            pos: cc.v2(0, 0)
        },
        135: {
            //洛阳杠次
            kaifang: true,
            prefabName: "GameChooseIcon",
            iconName: "DT_lymj",
            atlasName: "ChooseGameIcon.plist",
            channel: "", // 渠道（BG, AG）
            type: 0,
            isRealPerson: false,
            game_type: "",
            pos: cc.v2(0, 0)
        },
        136: {
            //血流麻将
            kaifang: true,
            prefabName: "GameChooseIcon",
            iconName: "DT_xlch",//"DT_srlf",
            atlasName: "ChooseGameIcon.plist",
            channel: "", // 渠道（BG, AG）
            type: 0,
            isRealPerson: false,
            game_type: "",
            pos: cc.v2(0, 0)
        },
        137: {
            //转转麻将
            kaifang: true,
            prefabName: "GameChooseIcon",
            iconName: "DT_hbzzmj",
            atlasName: "ChooseGameIcon.plist",
            channel: "", // 渠道（BG, AG）
            type: 0,
            isRealPerson: false,
            game_type: "",
            pos: cc.v2(0, 0)
        },
        138: {
            //贵阳捉鸡麻将
            kaifang: true,
            prefabName: "GameChooseIcon",
            iconName: "DT_gyzjmj",
            atlasName: "ChooseGameIcon.plist",
            channel: "", // 渠道（BG, AG）
            type: 0,
            isRealPerson: false,
            game_type: "",
            pos: cc.v2(0, 0)
        },
        139: {
            //卡五星麻将
            kaifang: true,
            prefabName: "GameChooseIcon",
            iconName: "DT_kwx",
            atlasName: "ChooseGameIcon.plist",
            channel: "", // 渠道（BG, AG）
            type: 0,
            isRealPerson: false,
            game_type: "",
            pos: cc.v2(0, 0)
        },
        140: {
            //长沙麻将
            kaifang: true,
            prefabName: "GameChooseIcon",
            iconName: "DT_csmj",
            atlasName: "ChooseGameIcon.plist",
            channel: "", // 渠道（BG, AG）
            type: 0,
            isRealPerson: false,
            game_type: "",
            pos: cc.v2(0, 0)
        },
        141: {
            //武汉麻将
            kaifang: true,
            prefabName: "GameChooseIcon",
            iconName: "DT_whmj",
            atlasName: "ChooseGameIcon.plist",
            channel: "", // 渠道（BG, AG）
            type: 0,
            isRealPerson: false,
            game_type: "",
            pos: cc.v2(0, 0)
        },
        142: {
            //内江麻将
            kaifang: true,
            prefabName: "GameChooseIcon",
            iconName: "DT_njmj",
            atlasName: "ChooseGameIcon.plist",
            channel: "", // 渠道（BG, AG）
            type: 0,
            isRealPerson: false,
            game_type: "",
            pos: cc.v2(0, 0)
        },
        143: {
            //哈尔滨麻将
            kaifang: true,
            prefabName: "GameChooseIcon",
            iconName: "DT_hebmj",
            atlasName: "ChooseGameIcon.plist",
            channel: "", // 渠道（BG, AG）
            type: 0,
            isRealPerson: false,
            game_type: "",
            pos: cc.v2(0, 0)
        },
        144: {
            //沈阳麻将
            kaifang: true,
            prefabName: "GameChooseIcon",
            iconName: "DT_symj",
            atlasName: "ChooseGameIcon.plist",
            channel: "", // 渠道（BG, AG）
            type: 0,
            isRealPerson: false,
            game_type: "",
            pos: cc.v2(0, 0)
        },
        145: {
            //石家庄麻将
            kaifang: true,
            prefabName: "GameChooseIcon",
            iconName: "DT_hbsjzmj",
            atlasName: "ChooseGameIcon.plist",
            channel: "", // 渠道（BG, AG）
            type: 0,
            isRealPerson: false,
            game_type: "",
            pos: cc.v2(0, 0)
        },
        146: {
            //安阳麻将
            kaifang: true,
            prefabName: "GameChooseIcon",
            iconName: "DT_aymj",
            atlasName: "ChooseGameIcon.plist",
            channel: "", // 渠道（BG, AG）
            type: 0,
            isRealPerson: false,
            game_type: "",
            pos: cc.v2(0, 0)
        },
        147: {
            //焦作麻将
            kaifang: true,
            prefabName: "GameChooseIcon",
            iconName: "DT_jzmj",
            atlasName: "ChooseGameIcon.plist",
            channel: "", // 渠道（BG, AG）
            type: 0,
            isRealPerson: false,
            game_type: "",
            pos: cc.v2(0, 0)
        }
    };


    init() {
        this.curMenu = this.menu.chat;
        this.curMenuType = this.menuType.allGame;
        this.getNearest();
    }
    setMenu(type) {
        this.curMenu = type;
    }
    getMenu() {
        return this.curMenu;
    }

    setMenuType(type) {
        this.curMenuType = type || this.menuType.allGame;
    }
    getMenuType() {
        return this.curMenuType;
    }

    getMenuInfoByType(type) {
        var _info = {};
        _info = this.menuInfo[type];
        return _info;
    }
    getMenuNameByType(type) {
        var _info;
        var _name = "";
        _info = this.menuInfo[type];
        if (_info) {
            _name = _info.menuName;
        }
        return _name;
    }
    getGameListByType(type) {
        var _info;
        var _games = [];
        _info = this.menuInfo[type];
        if (_info) {
            _games = _info.gameList;
        }
        return _games;
    }

    getgameInfoByGameId(gameId) {
        var _info = null;
        _info = this.gameListInfo[gameId];
        return _info;
    }

    setGameList(type, games) {
        // let _gameList = this.menuInfo[type]["gameList"];
        this.menuInfo[type]["gameList"].length = 0;
        for (var i = 0; i < games.length; i++) {
            this.menuInfo[type]["gameList"].push(games[i]);
        }

    }
    getNearest() {
        var _player = cc.vv.session.getPlayer();
        let _gameList = cc.vv.GLCusStorage.getItem("nearest_game" + "_" + _player.rid);
        if (!_gameList) {
            this.menuInfo[this.menuType.nearest]["gameList"] = [];
        } else {
            this.menuInfo[this.menuType.nearest]["gameList"] = _gameList.split(",");//JSON.parse(_gameList);
        }
    }
    setNearest() {
        var _player = cc.vv.session.getPlayer();
        cc.vv.GLCusStorage.setItem("nearest_game" + "_" + _player.rid, this.menuInfo[this.menuType.nearest]["gameList"]);
    }
    addNearest(gameId) {
        let _gameList = this.menuInfo[this.menuType.nearest]["gameList"];
        for (var i = 0; i < _gameList.length; i++) {
            if (gameId == _gameList[i]) {
                break;
            }
        }
        _gameList.splice(i, 1);
        _gameList.splice(0, 0, gameId);
        this.setNearest();
    }

    setbuildGames(index, games) {
        if (index < 0 || index >= this.buildGames.length) {
            return;
        }
        this.buildGames[index] = games.slice(0);

    }
}

export let gameChooseConfig: GameChooseConfig = new GameChooseConfig();
